package com.design.blog.controller;

import com.design.blog.model.R;
import com.design.blog.service.impl.ArticleServiceImpl;
import com.design.blog.service.impl.UserinfoServiceImpl;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author hxg
 * @version 1.0
 * @date 2022/3/15 22:03
 */
@RestController
@RequestMapping("/user")
public class UserController {
    @Resource
    private UserinfoServiceImpl userinfoService;

    @Resource
    private ArticleServiceImpl articleService;

    @GetMapping("curUser")
    public R getCurUserInfo(@RequestHeader("Authorization") String token) {
        return R.success(userinfoService.getUserInfo(token));
    }

    @GetMapping("deleteOwnArticle/{id}")
    public R deleteOwnArticle(@PathVariable("id") String id) {
        return R.success(articleService.removeById(id));
    }

}
